package mrdemo003;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class SortReduce extends Reducer<LongWritable, Text, LongWritable, IntWritable>{
	
	//序号计数器（所有的数据都汇聚到这个reduce处理中）
	private IntWritable num = new IntWritable(1);
	
	 
	 @Override
	protected void reduce(LongWritable k2, Iterable<Text> v2s,
			Reducer<LongWritable, Text, LongWritable, IntWritable>.Context context)
			throws IOException, InterruptedException {
		 //输出： 数据  排序值
		 
		 for(Text v : v2s) {
				 context.write(k2, num);
				 num = new IntWritable(num.get() + 1);
			 }
		 }
	 
}
